/**
 * @Author: liangwanlang
 * @Date:   2023-03-20 14:36:15
 * @Last Modified by:   liangwanlang
 * @Last Modified time: 2023-03-20 15:06:42
 */


function openNewWindow (url) {
    const strUrl = url;
    let a = document.createElement("a");
    document.body.appendChild(a);
    a.style = "display: none";
    a.target = "_blank";
    a.href = strUrl;
    a.click();
    document.body.removeChild(a);
}
var vm = new Vue({
    el: '#app',
    data () {
        //这里存放数据
        return {
            open_shear_plate_update: (info, tab) => {
                console.log(`data ~ info`, info);
                console.log(`data ~ tab`, tab);
                let menu = ['history', 'cookies', 'note'];
                let url = "chrome-extension://ncopbbkdlbjafgepcnhjmgecclfemkad/Pages/history/index.html?key=" + tab.url;
                openNewWindow(url)
            },
        }
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
        openHomeHandle (name) {
            console.log(` ====>>> 40 index `, openHomeHandle)
            ChromePlus.NavigateTo(name)
        },
        // 新增右键菜单
        addContextMenus () {
            const options = {
                type: 'normal',
                id: '1',
                title: 'cookies',
                visible: true,
                onclick: this.open_shear_plate_update
            }
            chrome.contextMenus.create(options, (err) => {
                console.log(`chrome.contextMenus.create ~ succses`,);
            });
        },
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created () {
        chrome.contextMenus.removeAll()
        // 注册右键菜单 
        this.addContextMenus();
        console.log(` created 默认启动页面,注册右键菜单`);
    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted () {

    },
});
